<template>
  <div class="home">
    首页 {{index}}
    <button @click="jump">跳转的about</button>
    <button @click="add">++</button>
    <tabbar :tabs="tabbar" :num="num" @add="partAdd"></tabbar>
  </div>
</template>

<script>
// @ is an alias to /src
import { useRouter } from 'vue-router';
import { ref,computed,reactive,toRefs } from 'vue';
import Tabbar from '../components/tabbar.vue';
export default {
  name: 'Home',
  components: {
    Tabbar
  },
  // data(){

  // },
  // methods: {
    
  // },
  setup(){
    const router = useRouter();
    // console.log(router);
    const num = ref(6);
    const data = reactive({
      tabbar:['首页','分类']
    })
    const jump = () => {
      router.push({path:'/about',query:{id:3}});
    }
    const index = ref(5);
    
    const add = () => {
      index.value++
      console.log(index.value);
    }
    const partAdd = (val) => {
      // console.log(val);
      num.value++
    }
    return {
      jump,
      add,
      index,
      ...toRefs(data),
      num,
      partAdd
    }
  }
}
</script>
